Skip to content

Conversation

@namgyu-youn
Copy link
Contributor

@namgyu-youn namgyu-youn commented Nov 30, 2025

Summary:
The HQQ unit test is added because there was only an e2e test.

Test Plan:

pytest -sv test/quantization/test_quant_primitives.py

Related Issue/PR: #3156 (comment)

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 30, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/3403

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 1 New Failure

As of commit f7323e3 with merge base 5d519d9 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 30, 2025
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 30, 2025

❌ 🤖 pytorchbot command failed:

Got EOF while in a quoted string```
Try `@pytorchbot --help` for more info.

@namgyu-youn
Copy link
Contributor Author

@pytorchbot label "topic: performance"

@pytorch-bot pytorch-bot bot added the topic: performance Use this tag if this PR improves the performance of a feature label Nov 30, 2025
@property
def max_gen_toks(self):
return 50
return 512
Copy link
Contributor Author

@namgyu-youn namgyu-youn Nov 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is updated because the GSM8K task is CoT reasoning (long-context)

@namgyu-youn
Copy link
Contributor Author

namgyu-youn commented Nov 30, 2025

cc @metascroy can you take a look into this? I will move to E2E support for SINQ after this PR as we talked with #3156 (comment); we can add SINQ to this e2e benchmark I feel.

@metascroy
Copy link
Contributor

Thanks! The unit test looks good to me. I'll let @jainapurva review the benchmark script, as I'm less familiar with that part of the codebase and if there are coding standards that are usually followed.

@jerryzh168
Copy link
Contributor

intx is targeting mobile right? so testing performance on server doesn't seem to be helpful?

@namgyu-youn namgyu-youn changed the title Build PERF for HQQ vs. Affine Add unit test for HQQ Dec 10, 2025
@namgyu-youn
Copy link
Contributor Author

namgyu-youn commented Dec 10, 2025

intx is targeting mobile right? so testing performance on server doesn't seem to be helpful?

@jerryzh168 Sorry I misunderstood the difference between intx (ExecuTorch/mobile) and int4 (CUDA), and actually my use case is CUDA (not mobile) deployment. Working more for int4 should be better to me, so I will move to SINQ support for int4 (as talked with #3106 (comment)).

@namgyu-youn
Copy link
Contributor Author

namgyu-youn commented Dec 10, 2025

Thanks! The unit test looks good to me. I'll let @jainapurva review the benchmark script, as I'm less familiar with that part of the codebase and if there are coding standards that are usually followed.

@metascroy Updated PR for only adding the HQQ unit test (drop intx benchmark). Please check the above comment.

Let me know if a dropped benchmark would be needed for ExecuTorch; if needed, I will submit a PR for ExecuTorch.

@metascroy
Copy link
Contributor

Thanks! The unit test looks good to me. I'll let @jainapurva review the benchmark script, as I'm less familiar with that part of the codebase and if there are coding standards that are usually followed.

@metascroy Updated PR for only adding the HQQ unit test (drop intx benchmark). Please check the above comment.

Let me know if a dropped benchmark would be needed for ExecuTorch; if needed, I will submit a PR for ExecuTorch.

The benchmark isn't necessary for ExecuTorch.

@metascroy
Copy link
Contributor

PR looks good! If unit tests pass, we can merge.

iters=20,
)

# Check quantized data shape and dtype
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test doesn't look very hard to pass? would it be better to make it stronger by comparing with the results of

"_choose_qparams_and_quantize_affine_hqq",
?

Copy link
Contributor Author

@namgyu-youn namgyu-youn Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding intx+hqq to

elif s == "int4_groupwise_hqq_weight_only":
return Int4WeightOnlyConfig(
group_size=32,
int4_packing_format="tile_packed_to_4d",
int4_choose_qparams_algorithm="hqq",
)

instead of comparing them here? Both are different HQQ implementation (optmized for NVIDIA vs. no HW optimization), so a sanity check might not work well here. If we need to compare them, we can do some experiments with the new eval script I feel.

Comment on lines +897 to +898
self.assertFalse(torch.isnan(reconstructed).any())
self.assertEqual(reconstructed.shape, input.shape)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here can we compare reconstructed with original input (with sqnr) to make sure they are close?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to compare reconstruction error, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: performance Use this tag if this PR improves the performance of a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants